#!/usr/evn/bin python
#coding:utf-8

import re
import sys


def mc(ls):
    def _mc(pa, ls):
        pa = re.compile(pa)
        for i in ls:
            if pa.search(i):
                yield 1
            else:
                yield 0

    lslen = len(ls)
    def s(pa, discript=""):
        ssum = sum(_mc(pa, ls))
        return "%s%s  %.3f%%" % (discript and discript + ": " or "", ssum, ssum*100.0/lslen)

    return s

def main(filename):
    ls = map(lambda x: x.strip(), open(filename).readlines())

    gor = mc(ls)

    print gor("_slice", "分片")
    print gor("_slice_/slice/button/follow/", "推荐按钮")
    print gor("^.{32}$", "Session")
    print gor("PASSPORT_FOLLOWERCOUNT_UKEY_", "用户follow数")
    print gor("USER_SEARCH_", "用户搜索")
    print gor("_pgcache_CALL", "pgcache")
    print gor("reply_list", "pgclient")



if __name__ == "__main__":
    main(sys.argv[1] if len(sys.argv) > 1 else "memcacheKey_201108231626.txt")
